<template>
    <div class="app-container">
      <label>库房采购单</label>
      <el-table v-loading="loading" :data="caigouList" @selection-change="handleSelectionChange">
        <el-table type="selection" width="55" align="center" />
        <el-table-column label="ID" align="center" prop="caigouid" />
        <el-table-column label="药品" align="center" prop="caigouname" />
        <el-table-column label="供货商" align="center" prop="gonghuoshang" />
        <el-table-column label="单位" align="center" prop="danwei" />
        <el-table-column label="产地" align="center" prop="candi" />
        <el-table-column label="类型" align="center" prop="leixing" />
        <el-table-column label="预计采购数量" align="center" prop="shuliang" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['warehouse:caigou:remove']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
  
    </div>
  </template>
  
  <script>
  import { listCaigou,delCaigou} from "@/api/warehouse/caigou";
  
  export default {
    name: "Caigou",
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          drugstoreName: null
        },
        // 总条数
        total: 0,
        // 采购表格数据
        caigouList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询采购列表 */
      getList() {
        this.loading = true;
        listCaigou(this.queryParams).then(response => {
          this.caigouList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const caigouids = row.caigouid || this.ids;
        this.$modal.confirm('是否确认删除采购编号为"' + caigouids + '"的数据项？').then(function() {
          return delCaigou(caigouids);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        }).catch(() => {});
      },
     
    }
  };
  </script>
  